<script setup lang='ts'>
import {ref} from 'vue'
import { DownOutlined,GlobalOutlined} from "@ant-design/icons-vue"
import {useLang} from "@/hooks/useLang"


const {lang,setLang,t}=useLang()
const selectedKeys=ref([lang.value])

function handleSelect(e:any){
  selectedKeys.value[0]=e.key
  // console.log(e,selectedKeys.value)
  if(e.key!=lang.value) {
    setLang(e.key)
    console.log("使用i18n配置的语言",t("global.toggle"))
  }
}
</script>

<template>
  <a-dropdown placement="bottom">
    <a style="color: white;" @click.prevent>
      <global-outlined style="font-size: 20px;" />
      <!-- <DownOutlined /> -->
    </a>
    <template #overlay>
      <a-menu
      v-model:selectedKeys="selectedKeys"
       @click="handleSelect"
      >
        <a-menu-item key="zh">
          <a href="javascript:;">中文</a>
        </a-menu-item>
        <a-menu-item key="en">
          <a href="javascript:;">英文</a>
        </a-menu-item>
      </a-menu>
    </template>
  </a-dropdown>
</template>

<style scoped>

</style>